Skip to content

feat: add --merge-file / -M CLI option for deep merging#42

Merged
candleindark merged 3 commits intodandi:mainfrom
candleindark:enh-add-merge-file-option
Mar 24, 2026
Merged

feat: add --merge-file / -M CLI option for deep merging#42
candleindark merged 3 commits intodandi:mainfrom
candleindark:enh-add-merge-file-option

Conversation

@candleindark
Copy link
Copy Markdown
Member

Closes #41.

Summary

  • Renames OverlayContentErrorYAMLContentError so the exception
    can serve both the overlay and the new deep-merge feature.
  • Adds a new -M / --merge-file CLI option that deep-merges a user-
    supplied YAML file into the generated schema using
    deepmerge. Values from the
    merge file win on conflict; no SchemaDefinition field filtering is
    applied (unlike -O).
  • The -M option is applied before -O in the post-processing
    pipeline.
  • Adds deepmerge as a runtime dependency.
  • Updates CLAUDE.md and README.md to document the new option and
    updated architecture.

Changes by commit

  1. refactor: rename OverlayContentError to YAMLContentError
    generalises the exception; updates all references and tests.
  2. feat: add --merge-file / -M CLI option for deep merging — adds
    apply_yaml_deep_merge() in tools.py, the -M CLI option, and
    TestCliDeepMerge + TestApplyYamlDeepMerge test classes.
  3. chore: apply ruff formatting and update documentation — ruff
    format pass; updates CLAUDE.md and README.md.

Test plan

  • hatch run test.py3.10:pytest tests/test_cli.py tests/test_tools.py::TestApplyYamlDeepMerge — all new tests pass
  • hatch run test.py3.10:pytest tests/ — full suite passes (3337 passed, 14 xfailed)
  • ruff check . — no lint errors
  • ruff format --check . — no formatting issues
  • hatch run types:check — no new type errors introduced
  • Smoke-tested -M with a nested merge against dandischema.models — a class-level description override was correctly merged while the rest of the schema was preserved

🤖 Generated with Claude Code

candleindark and others added 3 commits March 24, 2026 10:46
Generalize the exception name so it can be used for both the overlay
and the upcoming deep-merge feature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new -M / --merge-file option that deep-merges a YAML file into
the generated schema using deepmerge. Values from the merge file win on
conflict. Unlike -O, no field filtering is applied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ruff format applied to cli/__init__.py, tools.py, test_cli.py,
  test_tools.py
- CLAUDE.md: document new CLI options (-M, -O) and the updated
  tools/exceptions architecture
- README.md: add options table documenting -M, -O, -o, -l

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@candleindark candleindark merged commit 84e1063 into dandi:main Mar 24, 2026
13 checks passed
@candleindark candleindark deleted the enh-add-merge-file-option branch March 24, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to merge a partially specified LinkML schema to the generated schema

1 participant